package com.bysj.sausys.controller.portal;

import com.bysj.sausys.common.JsonData;
import com.bysj.sausys.model.SysDicParams;
import com.bysj.sausys.service.ISysDicParamsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 字典数据Controller
 *
 * @author WangZK
 */
@Api(description = "字典数据接口")
@Controller
@RequestMapping("/dicParams")
public class DicParamsController {

    @Resource
    private ISysDicParamsService sysDicParamsService;

    /**
     * 根据字典类型获取字典数据
     *
     * @param type
     * @return
     */
    @ApiOperation(value = "根据字典类型获取字典数据接口")
    @RequestMapping(value = "/getDicParamsByType", method = RequestMethod.GET)
    @ResponseBody
    public JsonData getDicParamsByType(@ApiParam(value = "字典类型", required = true) @RequestParam String type) {
        List<SysDicParams> sysDicParamsList = sysDicParamsService.getDicParamsByPmappname(type);
        return JsonData.success(sysDicParamsList);
    }

    /**
     * 根据字典类型获取双层级联的字典数据
     *
     * @param type
     * @return
     */
    @ApiOperation(value = "根据字典类型获取双层级联的字典数据接口")
    @RequestMapping(value = "/getDoubleLayerCascadeDicParams", method = RequestMethod.GET)
    @ResponseBody
    public JsonData getDoubleLayerCascadeDicParams(@ApiParam(value = "字典类型", required = true) @RequestParam String type) {
        List<Map> mapList = sysDicParamsService.getDoubleLayerCascadeDicParams(type);
        return JsonData.success(mapList);
    }

}